import React, { FC } from 'react';
import FormRender from '@/plugins/form/form-render';
import H5Components from '@/plugins/form/form-components';
import createDOMForm from '@/components/rc-form/createDOMForm';

import {
  parseFormData,
  parseValue
} from '@/plugins/form/form-render/utils/detail-parser';
import Data from './data';
import styles from './index.module.less';

const FormDetail: FC<any> = (props) => {
  // 合并值和json
  const formParsed = parseFormData(
    Data.data.formData.formModelData,
    'all',
    false
  );
  const formValues = parseValue(Data.data.formData.formValues);

  return (
    <div className={styles.formDetail}>
      <FormRender
        renderMode="detail"
        form={props.form}
        componentClasses={H5Components}
        value={formParsed}
        formValues={formValues}
      />
    </div>
  );
};

export default createDOMForm()(FormDetail);